package cn.xxm.strategy.pay.context;



import cn.xxm.strategy.pay.handler.PaySourceHandler;
import cn.xxm.strategy.pay.util.SpringUtil;

import java.util.Map;


public class SourceHandlerContext {
	
	private Map<String,Class<?>> handlerMap;

	public SourceHandlerContext(Map<String, Class<?>> handlerMap) {
		this.handlerMap = handlerMap;
	}
	

	public PaySourceHandler getInstance(String source) {
		Class<?> clazz =handlerMap.get(source);
		if(clazz ==null) {
			throw new RuntimeException("not found handler for source:"+source);
		}
		return (PaySourceHandler) SpringUtil.getBean(clazz);
	}

}
